home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / STREDITO.H < prev    next >
C/C++ Source or Header  |  1980-01-03  |  3KB  |  87 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * StringEditor - interactive editor for character strings
  25.  */
  26.  
  27. #ifndef streditor_h
  28. #define streditor_h
  29.  
  30. #include <InterViews/interactor.h>
  31.  
  32. static const char* SEDone = "\r\t\007\033";
  33.  
  34. static const char SEBeginningOfLine = '\001';
  35. static const char SEEndOfLine = '\005';
  36. static const char SESelectAll = '\025';
  37. static const char SESelectWord = '\027';
  38. static const char SEPreviousCharacter = '\002';
  39. static const char SENextCharacter = '\006';
  40. static const char SEDeleteNextCharacter = '\004';
  41. static const char SEDeletePreviousCharacter = '\177';
  42. static const char SEDeletePreviousCharacterAlt = '\010';
  43.  
  44. class ButtonState;
  45. class TextDisplay;
  46. class TextBuffer;
  47.  
  48. class StringEditor : public Interactor {
  49. public:
  50.     StringEditor(ButtonState*, const char* sample, const char* done = SEDone);
  51.     StringEditor(
  52.         const char* name, ButtonState*, const char*, const char* = SEDone
  53.     );
  54.     virtual ~StringEditor();
  55.  
  56.     void Message(const char* text);
  57.     void Select(int);
  58.     void Select(int left, int right);
  59.     void Edit();
  60.     void Edit(const char* text, int left, int right);
  61.  
  62.     const char* Text();
  63.  
  64.     virtual void Handle(Event&);
  65.     virtual void Reconfig();
  66. protected:
  67.     virtual boolean HandleChar(char);
  68.     void InsertText(const char*, int);
  69.     void DoSelect(int left, int right);
  70.  
  71.     virtual void Redraw(Coord, Coord, Coord, Coord);
  72.     virtual void Resize();
  73.  
  74.     TextBuffer* text;
  75.     int left, right;
  76.     ButtonState* subject;
  77.     const char* done;
  78.     const char* sample;
  79.     char* buffer;
  80.     int size;
  81.     TextDisplay* display;
  82. private:
  83.     void Init(ButtonState*, const char*, const char*);
  84. };
  85.  
  86. #endif
  87.